﻿// Author: Jin Qing (http://blog.csdn.net/jq0123)

#ifndef SVR_COMMON_CLIENT_MAILBOX_H
#define SVR_COMMON_CLIENT_MAILBOX_H

#include "mailbox.h"
#include "message_sptr.h"

// Client mail box is used to send messages to client.
class CClientMailBox : public CMailBox
{
public:
	CClientMailBox();

public:
	void SetCltEndpoint(const std::string& sCltAddr, uint16_t uCltPort)
	{
		m_sCltAddr = sCltAddr;
		m_uCltPort = uCltPort;
	}
	const std::string& GetCltAddr() const
	{
		return m_sCltAddr;
	}
	uint16_t GetCltPort() const
	{
		return m_uCltPort;
	}

public:
	// ServerMb should not response, only request.
	// Only ClientMb can response Rpc.
	void PushRpcResp(uint32_t uRpcId, const google::protobuf::Message& response);
	void PushRpcResp(uint32_t uRpcId, const std::string& sResponse);


private:
	std::string m_sCltAddr;
	uint16_t    m_uCltPort = 0;
};

#endif  // SVR_COMMON_SERVER_MAILBOX_H